#pragma once

#include <windows.h>
#include "CParticleManager.h"
#include "SGD Wrappers/CSGD_Direct3D.h"

class CParticle;

enum BlendType{ZERO,
				ONE,
				SOURCE_COLOR,
				INV_SOURCE_COLOR,
				SOURCE_ALPHA,
				INV_SOURCE_ALPHA,
				DEST_ALPHA,
				INV_DEST_ALPHA,
				DEST_COLOR,
				INV_DEST_COLOR,
				SOURCE_ALPHA_SAT,
				BOTH_SRC_ALPHA,
				BOTH_INV_SRC_ALPHA,
				BLEND_FACTOR,
				INV_BLEND_FACTOR};
				
class CEmitter
{
	vector<CParticle*> m_vecliveParticles;
	vector<CParticle*> m_vecdeadParticles;
	int m_nParticlesOnScreen;
	unsigned int m_nMaxParticles;
	float m_fPosX;
	float m_fPosY;
	float m_fMinVelX;
	float m_fMaxVelX;
	float m_fMinVelY;
	float m_fMaxVelY;
	int	  m_nImageID;
	//RECT  m_rDrawRect;
	unsigned int m_uistartBlendMode;
	unsigned int m_uidestBlendMode;
	int m_nMaxLifespan;
	int m_nMinLifespan;
	int m_nParticleCount;
	float Xgrav;
	float Ygrav;
	float timer;
	float scale;
	float m_fEmissionRate;
	bool clearingList;
	bool Spread;
	bool Play;
	D3DXCOLOR startColor;
	D3DXCOLOR endColor;

public:

	//Accessors
	bool GetPlay()							{return Play;}
	//Modifiers
	void SetPosX(float X)					{m_fPosX = X;}
	void SetPosY(float Y)					{m_fPosY = Y;}
	void SetMinXVel(float velXmin)			{m_fMinVelX = velXmin;}
	void SetMaxXVel(float velXmax)			{m_fMaxVelX = velXmax;}
	void SetMinYVel(float velYmin)			{m_fMinVelY = velYmin;}
	void SetMaxYVel(float velYmax)			{m_fMaxVelY = velYmax;}
	void SetImage(int ID)					{m_nImageID = ID;}
	void SetStartBlend(unsigned int Blend)	{m_uistartBlendMode = Blend;}
	void SetDestBlend(unsigned int Blend)	{m_uidestBlendMode = Blend;}
	void SetMaxLife(int max)				{m_nMaxLifespan = max;}
	void SetMinLife(int min)				{m_nMinLifespan = min;}
	void SetNumParticle(int num)			{m_nMaxParticles = num;}
	void SetXGrav(float xGrav)				{Xgrav = xGrav;}
	void SetYGrav(float yGrav)				{Ygrav = yGrav;}
	void SetStartColor(D3DXCOLOR scolor)	{startColor = scolor;}
	void SetEndColor(D3DXCOLOR ecolor)		{endColor = ecolor;}
	void SetScale(float Scale)				{scale = Scale;}
	void SetEmissionRate(float Rate)		{m_fEmissionRate = Rate;}
	void SetSpread(bool spread)				{Spread = spread;}
	void PlayEffect(bool play)				{Play = play;}
	CEmitter();
	~CEmitter();

	void Init();
	void Update(float fDelta);
	void Shutdown();
	void Render();
	void AddParticle();
	void ClearLists();

};